STCOR-950 Added location
to a hook in <MainNav>
to fix comparing old location
value
#1600
+2
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
After the switch to hooks, in stripes-core/src/components/MainNav/MainNav.js at 3570eea0bca50bb0abb0cc0e52db3ae4bc3a792e · folio-org/stripes-core
location
object is not updated, and sostore.subscribe
callback always uses an old value.When
updateLocation
comparescleanStateQuery
andcleanLocationQuery
objects, they are always different because we’re comparing to an oldlocation
This caused a bug in Inventory, where when a user opens a shared record - the page reloads and user is taken back to search results. This happens because when a user opens a shared record we append
shared=true
to the url. And because<MainNav>
doesn't compare to a current url the flow gets interrupted.If we add location to the hook’s deps it works as expected.
Screenshots
chrome_ihYEknGL4o.mp4
Issues
STCOR-950